package jtk.project4.fleet.field;

import java.awt.Dimension;

import javax.swing.ComboBoxModel;

import jtk.project4.fleet.domain.PartHist;

import nl.coderight.jazz.form.FormLayout;
import nl.coderight.jazz.form.FormLayout.Resize;
import nl.coderight.jazz.form.control.GroupControl;
import nl.coderight.jazz.form.field.ComboField;
import nl.coderight.jazz.form.field.SpinnerField;
import nl.coderight.jazz.form.field.TextField;
import nl.coderight.jazz.form.field.button.CheckButton;

public class AddPartUsedField extends GroupControl<PartHist>{
	private TextField nameField;
	private TextField descriptionField;
	private TextField unitCostField;
	private TextField extendedCostField;
	//private ComboField<String> partField;
	private TextField partField;
	private ComboField<String> warehouseField;
	private ComboField<String> vendorField;
	private ComboField<String> costCenterField;
	private ComboField<String> purchaseOrderField;
	private SpinnerField<Integer> quantityUsedField;
	private CheckButton underWarranty;
	
	
	
	public AddPartUsedField(String bindID) {
		// TODO Auto-generated constructor stub
		setTitle("header.AddPartUsedField");
		setBindID(bindID);
		createFields();
		createLayout();
	}
	
	private void createFields(){
		//new GeneralInformationField("partHist");
		nameField = new TextField("name",35);
		descriptionField = new TextField("desc",35);
		
		unitCostField = new TextField("unitCost", 15);
		unitCostField.setRequired(true);
		
		extendedCostField = new TextField("eCost", 15);
		extendedCostField.setRequired(true);
		
		partField = new TextField("partNo", 15);
		partField.setRequired(true);
		
		warehouseField = new ComboField<String>("warehouseID", "warehouseID");
		warehouseField.setPreferredSize(unitCostField.getPreferredSize());
		
		vendorField = new ComboField<String>("vendorID", "vendorID");
		costCenterField = new ComboField<String>("costCenter", "costCenter");
		purchaseOrderField = new ComboField<String>("poNo", "poNo");
		
		quantityUsedField = new SpinnerField<Integer>("used", "used");
		quantityUsedField.setPreferredSize(unitCostField.getPreferredSize());
		quantityUsedField.insert(1, true);
		
		underWarranty = new CheckButton("Under Warranty");
	}
	
	private void createLayout() {
		setLayout(new FormLayout())
		.addRow()
		.addLabel("label.part#").addField(partField,Resize.HORIZONTAL)
		.addLabel("label.warehouse").addField(warehouseField,Resize.HORIZONTAL)
		.addRow()
		.addLabel("label.name")	.addField(nameField,Resize.HORIZONTAL)
		.addRow()
		.addLabel("label.description").addField(descriptionField,Resize.HORIZONTAL)
		.addRow()
		.addLabel("label.vendor").addField(vendorField,Resize.HORIZONTAL)
		.addLabel("label.PO#").addField(purchaseOrderField,Resize.HORIZONTAL)
		.addRow()
		.addLabel("label.cost center") .addField(costCenterField,Resize.HORIZONTAL)
		.addRow()
		.addLabel("label.quantity used").addField(quantityUsedField)
		.addRow()
		.addLabel("label.unit cost") .addField(unitCostField)
		.addRow()
		.addLabel("label.extended cost").addField(extendedCostField)
		.addField(underWarranty)
		;
	}
	
	
}
